var User = require("./userModel.js");

/**
 * [update 更新username为Tracy McGrady的userpwd]
 * @Author   zhanggongze
 * @DateTime 2017-05-26
 * @return   {[type]}    [obj]
 */
function update(){
    var wherestr = {'username' : 'Tracy McGrady'};
    var updatestr = {'userpwd': '3281130'};
    
    User.update(wherestr, updatestr, function(err, res){
        if (err) {
            console.log("Error:" + err);
        }
        else {
            console.log("Res:" + res);
        }
    })
}

// update();

/**
 * [findByIdAndUpdate 根据ID 更新数据]
 * @Author   zhanggongze
 * @DateTime 2017-05-26
 * @return   {[type]}    [obj]
 */
function findByIdAndUpdate(){
    var id = '5927c665978548a51971fa2d';
    var updatestr = {'userpwd': 'abcd'};
    
    User.findByIdAndUpdate(id, updatestr, function(err, res){
        if (err) {
            console.log("Error:" + err);
        }
        else {
            console.log("Res:" + res);
        }
    })
}

findByIdAndUpdate();